<template>
  <div
    ref="chart"
    id="chart"
    :style="{width: '100%', height: '300px'}"
  />
</template>

<script lang="ts" setup>
import * as echart from 'echarts'
import { onMounted } from 'vue'

const initChart = () => {
  console.log(212)
  const chart = document.getElementById('chart')
  // const chart = ref<HTMLDivElement | null>(null)

  const salesChart = echart.init(chart as HTMLElement)
  salesChart.setOption({
    tooltip: {
      trigger: 'axis'

    },
    grid: { left: '1%', right: '1%', top: '2  %', bottom: 0, containLabel: true },
    xAxis: {
      type: 'category',
      data: [
        '1月',
        '2月',
        '3月',
        '4月',
        '5月',
        '6月',
        '7月',
        '8月',
        '9月',
        '10月',
        '11月',
        '12月'
      ]
    },
    yAxis: {
      type: 'value',
      max: 8000,
      splitNumber: 4
    },
    series: [
      {
        data: [3000, 2000, 3333, 5000, 3200, 4200, 3200, 2100, 3000, 5100, 6000, 3200, 4800],
        type: 'bar',
        barMaxWidth: 80,
        color: '#3aa1ff'
      }
    ]
  })
}

onMounted(() => {
  initChart()
})

</script>

<style lang="scss" scoped>

</style>
